package cn.lecosa.util

import java.util.Properties

import com.typesafe.config.ConfigFactory

import scalikejdbc.ConnectionPool
import scalikejdbc.ConnectionPoolSettings
import scalikejdbc.config.DBs
/**
 * Demo class
 *
 * @author administrator
 * @date 2018/9/19
 * @time 14:29
 */
object DBUtils extends Serializable {

  def getDbConnection() {
    val load = ConfigFactory.load
    DBs.setup()
  }
  /**
   * 初始化jdbc连接池
   * @param configPath
   */
  def initDbConnection(applicationConf: Properties): Unit = {
    val driver = applicationConf.getProperty("db.default.driver")
    val url = applicationConf.getProperty("db.default.url")
    val user = applicationConf.getProperty("db.default.user")
    val password = applicationConf.getProperty("db.default.passwords")

    val poolSettings = new ConnectionPoolSettings(driverName = driver)
    ConnectionPool.singleton(url, user, password, poolSettings)
  }
  def main(args: Array[String]): Unit = {
    println("hello")
//  initDbConnection(PropertyUtil.getProperties("D:/spark/workspace/cq_bigdata/resources/application.conf"))
    DmService.getBzhdmByYsmb("1").foreach(println)

  }

}
